package com.jiangjiang.eshop.wms.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiangjiang.eshop.wms.convert.ReturnGoodsInputOrderPutOnItemConvert;
import com.jiangjiang.eshop.wms.dao.ReturnGoodsInputOrderPutOnItemMapper;
import com.jiangjiang.eshop.wms.domain.ReturnGoodsInputOrderPutOnItem;
import com.jiangjiang.eshop.wms.dto.ReturnGoodsInputOrderPutOnItemDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @Author Jianghaowen
 * @Date 2021/9/28
 * @Description: TODO
 * @Version V1.0
 **/
@Service
public class ReturnGoodsInputOrderPutOnItemService extends ServiceImpl<ReturnGoodsInputOrderPutOnItemMapper, ReturnGoodsInputOrderPutOnItem> {
    @Autowired
    private ReturnGoodsInputOrderPutOnItemConvert returnGoodsInputOrderPutOnItemConvert;

    /**
     * 根据退货入库单明细id查询上架条目上架
     *
     * @param itemIds 退货入库单明细id集合
     * @return 查询结果
     */
    public List<ReturnGoodsInputOrderPutOnItemDTO> queryByItemIds(Set<Long> itemIds) {
        LambdaQueryWrapper<ReturnGoodsInputOrderPutOnItem> wrapper = Wrappers.lambdaQuery();
        wrapper.in(ReturnGoodsInputOrderPutOnItem::getReturnGoodsInputOrderItemId, itemIds);
        return returnGoodsInputOrderPutOnItemConvert.convertEnties2DTOList(this.list(wrapper));
    }

    /**
     * 批量保存退货入库单上架明细数据
     * @param putOnItemList
     */
    public void saveBatch(List<ReturnGoodsInputOrderPutOnItemDTO> putOnItemList) {
        this.saveBatch(returnGoodsInputOrderPutOnItemConvert.convertDTO2List(putOnItemList));
    }
}
